package org.iweb.html.impl.session;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.iweb.html.api.AppState;
import org.iweb.html.api.Observer;

public class AppSession implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4386423027218581474L;

	private String username;
	private String id;
	private Long lastAccess;
	private AppState appState;
	private Observer observer;
	private Map<String, Serializable> groovyScript;
	
	public AppSession() {
		setLastAccess(System.currentTimeMillis());
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public void setId(String id) {
		this.id=id;
	} 
	
	public String getId(){
		return this.id;
	}

	public Long getLastAccess() {
		return lastAccess;
	}

	public void setLastAccess(Long lastAccess) {
		this.lastAccess = lastAccess;
	}

	
	public AppState getAppState() {
		if(appState==null)
			appState=new AppState();
		return appState;
	}

	public void setAppState(AppState appState) {
		this.appState = appState;
	}
	
	public Observer getObserver() {
		if(observer==null)
			observer=new Observer();
		return observer;
	}

	public void setObserver(Observer observer) {
		this.observer = observer;
	}

	public Map<String, Serializable> getGroovyScript() {
		if(groovyScript==null)
			groovyScript=new HashMap<String, Serializable>();
		return groovyScript;
	}

	public void setGroovyScript(Map<String, Serializable> groovyScript) {
		this.groovyScript = groovyScript;
	}
	
}
